package com.shanzmoo.db.job.entity.dto;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.db.job.entity.ScheduleJobEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 定时任务保存信息
 *
 * @author： Gzhao 2020/12/24
 */
@Data
@ApiModel("定时任务保存信息")
public class ScheduleJobSaveDto {

    @ApiModelProperty(value = "任务ID")
    private Long jobId;

    @NotBlank(message = "spring bean名称不允许为空")
    @ApiModelProperty(value = "spring bean名称")
    private String beanName;

    @ApiModelProperty(value = "参数")
    private String params;

    @NotBlank(message = "cron表达式不允许为空")
    @ApiModelProperty(value = "cron表达式")
    private String cronExpression;

    @ApiModelProperty(value = "备注")
    private String remark;

    public ScheduleJobEntity convert() {
        return JSON.parseObject(JSON.toJSONString(this), ScheduleJobEntity.class);
    }
}
